package com.ty.controlller;

import com.ty.config.Minio;
import com.ty.service.MinioService;
import io.minio.MinioClient;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api("minio接口管理")
@RestController
@RequestMapping("/minio")
public class MinioController {

    @Autowired
    Minio minio;

    @Autowired
    MinioClient minioClient;

    @Autowired
    MinioService minioService;

    @PostMapping("/update")
    @ApiOperation("上传")
    public String update(MultipartFile file){
        String update = minioService.update(file);
        return update;
    }

    @GetMapping("/download")
    @ApiOperation("下载")
    public ResponseEntity <InputStreamResource> download(String url){
        ResponseEntity<InputStreamResource> download =minioService.download(url);
        return download;
    }


}
